<%@ page import="cn.myschool.entity.Subject" %>
<%@ page import="cn.myschool.severs.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        String subjectname=request.getParameter("subjectname");
        int classhour=Integer.parseInt(request.getParameter("classhour"));
        int gid=Integer.parseInt(request.getParameter("gradeid"));
        Subject sub=new Subject();
        sub.setSubjectname(subjectname);
        sub.setClasshour(classhour);
        sub.setGradeid(gid);
        int r=SubjectServer.ME.add2(sub);
        if(r>0){
            //表单重复提交：1）后退再提交 2）直接刷新
            //重定向，可以解决刷新一下，提交两次的问题
           response.sendRedirect("subject.jsp");
            // request.getRequestDispatcher("subject.jsp").forward(request,response);
        }else{
           // out.print("增加失败，可能课程名重复了！");
            request.setAttribute("msg","增加失败，可能课程名重复了！");
            request.getRequestDispatcher("subjectAdd.jsp").forward(request,response);
            //response.sendRedirect("subjectAdd.jsp");
        }
    %>
</body>
</html>
